# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=cloudfail
pkgver=79.7982c7d
pkgrel=6
pkgdesc="Utilize misconfigured DNS and old database records to find hidden IP's behind the CloudFlare network."
groups=('blackarch' 'blackarch-recon')
arch=('any')
url='https://github.com/m0rtem/CloudFail'
license=('custom:unknown')
depends=('python' 'python-requests' 'python-argparse' 'python-colorama'
         'python-beautifulsoup4' 'python-pysocks' 'python-pyopenssl'
         'python-win_inet_pton' 'python-dnspython')
makedepends=('git')
source=("$pkgname::git+https://github.com/m0rtem/CloudFail.git"
        'socks.py.patch')
sha512sums=('SKIP'
            'a8c9caa914bba81a29f469f2c3a10dd42c624aea3ddbab30167d88b6694dca9d44b9eccfb335481449d8dca459eb4030cbe00f0d946a9c2c24ddba1891cba987')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

prepare() {
  cd $pkgname

  patch -p0 < ../socks.py.patch
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  rm README.md

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec python3 $pkgname.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

